home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing.plaf.metal;
-
- import com.sun.java.swing.BoundedRangeModel;
- import com.sun.java.swing.JComponent;
- import com.sun.java.swing.JProgressBar;
- import com.sun.java.swing.plaf.ComponentUI;
- import com.sun.java.swing.plaf.basic.BasicProgressBarUI;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.Insets;
- import java.awt.Rectangle;
-
- public class MetalProgressBarUI extends BasicProgressBarUI {
- public static ComponentUI createUI(JComponent c) {
- return new MetalProgressBarUI();
- }
-
- public void paint(Graphics g, JComponent c) {
- super.paint(g, c);
- JProgressBar progressBar = (JProgressBar)c;
- BoundedRangeModel model = progressBar.getModel();
- Dimension size = ((Component)progressBar).getSize();
- Insets i = ((JComponent)progressBar).getInsets();
- Rectangle barRect = new Rectangle(size);
- barRect.x += i.left;
- barRect.y += i.top;
- barRect.width -= i.right + barRect.x;
- barRect.height -= i.bottom + barRect.y;
- int amountFull = ((BasicProgressBarUI)this).getAmountFull(c);
- if (progressBar.getOrientation() == 0) {
- g.setColor(MetalLookAndFeel.getControlShadow());
- g.drawLine(barRect.x, barRect.y, barRect.width, barRect.y);
- if (model.getValue() == model.getMinimum()) {
- g.setColor(MetalLookAndFeel.getControlShadow());
- } else {
- g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
- }
-
- g.drawLine(barRect.x, barRect.y, barRect.x, barRect.height);
- g.drawLine(barRect.x, barRect.y, amountFull, barRect.y);
- } else {
- g.setColor(MetalLookAndFeel.getControlShadow());
- g.drawLine(barRect.x, barRect.y, barRect.x, barRect.height);
- if (model.getValue() == model.getMinimum()) {
- g.setColor(MetalLookAndFeel.getControlShadow());
- } else {
- g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
- }
-
- g.drawLine(barRect.x, barRect.height, barRect.width, barRect.height);
- g.drawLine(barRect.x, barRect.height, barRect.x, barRect.height - amountFull);
- }
-
- }
- }
-